<template>
  <div>
      <!-- 绑定值 点击回车添加数据 -->
    <input type="text" v-model="username" placeholder="请输入你的任务名称，按回车键确认" @keyup.enter="hjwadd">
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
        // 定义一个值
      username: ""
    };
  },
  mounted() {},
  methods: {
    hjwadd() {
        // 判断是否为空
      if (this.username == "") {
        alert("请输入内容");
        return false;
      }
      console.log(this.username);
    //   传到vuex然后保存起来
      this.$store.commit("hjwadd", {
        username: this.username,
        hjwcheck: false
      });
      this.username = "";
    }
  },
  computed: {},
  components: {},
  watch: {},
  getters: {}
};
</script>

<style scoped>
input{
    width: 100%;
    height: 30px;
}
</style>